function numFormat (labelValue, n = 1) {
  let res = Math.abs(Number(labelValue)) >= 1.0e+9
      ? (Number(labelValue) / 1.0e+9).toFixed(n) + 'B'
      : Math.abs(Number(labelValue)) >= 1.0e+6
          ? (Number(labelValue) / 1.0e+6).toFixed(n) + 'M'
          : Math.abs(Number(labelValue)) >= 1.0e+3
              ? (Number(labelValue) / 1.0e+3).toFixed(n) + 'K'
              : (Number(labelValue)).toFixed(n)
  return res
}
function dateFormat(val) {
  let date = new Date(+val * 1000)
  let Y = date.getFullYear();
  let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1);
  let D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
  return formateToDate('' + Y + M + D)
}
function dateTimeFormat(val) {
  let date = new Date(+val * 1000)
  let Y = date.getFullYear();
  let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1);
  let D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
  return Y + '-' + M + '-' + D
}

function formateToDate(val) {
  if(val) {
    val += ''
    let date = val.substring(4)
    return date.substring(0,2) + '-' + date.substring(2)
  }
  return ''
}

function toThousands(num) {
  let result = [ ], counter = 0;
  let isNegative = (+num < 0)
  if(isNegative) {
    num = num.toString().substring(1)
  }
  num = (num || 0).toString().split('')
  for (let i = num.length - 1; i >= 0; i--) {
    counter++;
    result.unshift(num[i]);
    if (!(counter % 3) && i !== 0) { result.unshift(','); }
  }
  return isNegative? '-' + result.join('') : result.join('');
}